Whenever I release any instance that could exists or not, I am using this code:
if(myObject!=nil)
{
[myObject release];
}
but I have a confusion, sending a message to nil is not a problem;
I want to know, is that condition necessary?
Home / DeveloperSection / Forums / Is condition is necessary before releasing instance
Whenever I release any instance that could exists or not, I am using this code:
if(myObject!=nil)
{
[myObject release];
}
but I have a confusion, sending a message to nil is not a problem;
I want to know, is that condition necessary?
Tarun Kumar
04-Nov-2015There is no need to check nil, because by default Objective C checks for nil,
So there is no need to check it twice.
but, you can do some extra code with that object here, before releasing the object.